5bcda0
@@ -60,6 +60,10 @@
   transient Deserializer scriptOutputDeserializer;
   transient volatile Throwable scriptError = null;
 
+  /**
+   * Timer to send periodic reports back to the tracker.
+   */
+  transient Timer rpTimer;
   /**
    * addJobConfToEnvironment is shamelessly copied from hadoop streaming.
    */
@@ -214,6 +218,22 @@
public void initialize(Configuration hconf, Reporter reporter, ObjectInspector[]
                                    (HiveConf.getIntVar(hconf, HiveConf.ConfVars.SCRIPTERRORLIMIT)),
                                    "ErrorProcessor");
       errThread.start();
+      
+      /* Timer that reports every 5 minutes to the jobtracker. This ensures that even if
+         the user script is not returning rows for greater than that duration, a progress
+         report is sent to the tracker so that the tracker does not think that the job 
+         is dead.
+      */
+      Integer exp_interval = null;
+      int exp_int;
+      exp_interval = Integer.decode(hconf.get("mapred.tasktracker.expiry.interval"));
+      if (exp_interval != null)
+        exp_int = exp_interval.intValue() / 2;
+      else
+        exp_int = 300000;
+
+      rpTimer = new Timer(true);
+      rpTimer.scheduleAtFixedRate(new ReporterTask(reporter), 0, exp_interval);
 
     } catch (Exception e) {
       e.printStackTrace();
@@ -256,6 +276,7 @@
public void close(boolean abort) throws HiveException {
           new_abort = true;
         };
       } catch (IOException e) {
+        LOG.error("Got ioexception: " + e.getMessage());
         new_abort = true;
       } catch (InterruptedException e) { }
     }
@@ -443,4 +464,25 @@
public void run() {
   public String getName() {
     return "SCR";
   }
+  
+  class ReporterTask extends TimerTask {
+    
+    /**
+     * Reporter to report progress to the jobtracker.
+     */
+    private Reporter rp;
+    
+    /**
+     * Constructor.
+     */
+    public ReporterTask(Reporter rp) {
+      if (rp != null)
+        this.rp = rp;
+    }
+    
+    @Override
+    public void run() {
+      rp.progress();
+    }
+  }
 }
